package com.listview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.baidu.location.demo.R;
import com.bumptech.glide.Glide;

import java.util.List;

public class personalSettingAdapter extends ArrayAdapter {
    private List<PersonalSettingList> mData;
    private final int resourceId;
    public personalSettingAdapter(@NonNull Context context, int textViewResourceId,List<PersonalSettingList> data) {
        super(context, textViewResourceId, data);
        mData=data;
        this.resourceId = textViewResourceId;
    }

    @SuppressLint("ViewHolder")
    @Override
    public View getView(int i, View convertView, ViewGroup parent) {
        View view= LayoutInflater.from(getContext()).inflate(resourceId, null);
        PersonalSettingList data=mData.get(i);
        personalSettingView personalSetting=new personalSettingView();
        personalSetting.personalSettingName=view.findViewById(R.id.personalSettingName);
        personalSetting.personalSettingImage=view.findViewById(R.id.personalSettingImage);
        personalSetting.personalSettingName.setText(data.getName());
        Glide.with(getContext()).load(data.getId()).into(personalSetting.personalSettingImage);
        view.setOnClickListener(data.getL());
        return  view;
    }
    class personalSettingView{
        TextView personalSettingName;
        ImageView personalSettingImage;
    }
}
